#!/usr/bin/python
#coding:utf-8

import oauth2 as oauth
from oauthtwitter import OAuthApi

consumer_key = "A3Di73EDiyHM8u2IyxHLw"
consumer_secret = "pSSGT09FSR3ONawurMbEp5CLPeiptNs8XFwBxprEMI"

def get_auth_url():
    twitter = OAuthApi(consumer_key, consumer_secret)
    temp_credentials = twitter.getRequestToken()
    return temp_credentials,twitter.getAuthorizationURL(temp_credentials)

def get_access_token(credentials,oauth_verifier):
    twitter = OAuthApi(consumer_key, consumer_secret)
    access_token = twitter.getAccessToken(credentials, oauth_verifier)
    return access_token
    
def MakeApiCall(access_token, call, type="GET", Parameters={}):
    call = call.replace('api/','')
    if Parameters.has_key('status'):
        Parameters['status'] = Parameters['status'].encode('utf-8')
    twitter = OAuthApi(consumer_key, consumer_secret, access_token['oauth_token'], access_token['oauth_token_secret'])
    return twitter.ApiCall1(call,type,Parameters)
    
